#include<bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int dp_down[maxn] , dp_up[maxn] , a[maxn];
int ans_down , ans_up;
int main(){
	int n = 1;
	while(cin >> a[n]){
		dp_down[n] = 1;
		dp_up[n] = 1;
		n++;
	}
	n--;
	for(int i = 2 ; i <= n ; i++){
		for(int j = 1 ; j < i ; j++){
			if(a[j] >= a[i]){
				dp_down[i] = max(dp_down[i] , dp_down[j] + 1);
			}
			if(a[j] < a[i]){
				dp_up[i] = max(dp_up[i] , dp_up[j] + 1);
			}
		}
		ans_down = max(dp_down[i] , ans_down);
		ans_up = max(dp_up[i] , ans_up);
	}
	cout << ans_down << endl << ans_up;
}
